import util from '@/utils/util';

export default {
    /**
     * 格式化歌单音乐 列表
     * @param {Array} data 歌单详情数据
     */
    formatPlayList(data) {
        let arr = [];
        const { id, name, description, trackCount, playCount } = data.playlist;
        
        data.playlist.tracks.forEach(item => {
            arr.push({
                id: item.id,
                vid: item.id,
                name: item.name,
                author: item.ar[0].name,
                duration: util.formatDuration(item.dt),
                poster: `${item.al.picUrl}?param=34y34`,
                picUrl: item.al.picUrl
            });
        });

        data.playlist = { tracks: arr, trackCount, id, name, description, playCount};

        return data;
    },
    newDisk(data){
        let arr = data.albums.map(item => {
            return {
                id: item.id,
                name: item.name,
                picUrl: item.picUrl,
                type: item.type,
                subType: item.subType,
                artist: item.artist,
                tags: item.tags,
                artists: item.artists
            }
        });
        data.albums = arr;

        return data;
    }
}